﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataAccess;

namespace CaseStudy
{
    public partial class EditUser : System.Web.UI.Page
    {
        private DAUser daUser;
        protected void Page_Load(object sender, EventArgs e)
        {
            daUser = new DAUser();
            user selectedUser = daUser.selectUserByID(int.Parse(Request.QueryString["uid"].ToString()));
            txtFullname.Text = selectedUser.fullname;
            txtDescription.Text = selectedUser.description;
        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            daUser = new DAUser();
            if (txtNewPwd01.Text == txtNewPwd02.Text)
            {
                daUser.updateProfile(int.Parse(Request.QueryString["uid"].ToString()), txtFullname.Text, txtDescription.Text,
                                     txtNewPwd01.Text);
                Response.Redirect("UserManagement.aspx");
            }
        }
    }
}